package cn.itcast.rabbitmq.spring;

import cn.itcast.utils.MailUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;

public class BirEmailMqListener implements MessageListener {
    @Override
    public void onMessage(Message message) {
        try {
            byte[] body = message.getBody();
            String email = JSON.parseObject(body, String.class);
            MailUtil.sendMsg(email, "生日祝福", "祝你生日快乐!!!");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
